home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / PowerPC / Games / Battalion / source / gprim.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-23  |  35.7 KB  |  1,198 lines

  1. /****************************************************************/
  2. /* code copyright 1995-1996 Andrew Johnson - ALL RIGHTS RESERVED*/
  3. /*                          ajohnson@eecs.uic.edu               */
  4. /*                                                              */
  5. /*                      Electronic Visualization Lab (M/C 154)  */
  6. /*                      University of Illinois at Chicago       */
  7. /*                      851 South Morgan St. Room 1120 SEO      */
  8. /*                      Chicago, IL 60607-7053                  */
  9. /*                                                              */
  10. /*                      (312) 996-3002     (312) 413-7585 FAX   */
  11. /***********************************************************************/
  12. /* gprim.c  v 1.3                                                      */
  13. /* primitive graphics routines for battalion                           */
  14. /***********************************************************************/
  15.  
  16. #include "battalion.h"
  17.  
  18.     GLUquadricObj *qobj;
  19.  
  20.     float   pt1[3] = {1, -1, 1};
  21.     float   pt2[3] = {1, 1, 1};
  22.  
  23.     /*****************/
  24.     /* damaged cubes */
  25.     /*****************/
  26.  
  27.     float dcube[8][3] = {
  28.         -1.0,  1.0,  0.6,
  29.         -0.7, -0.9,  1.1,
  30.          0.8, -1.0,  0.9, 
  31.          1.0,  0.5,  1.0,
  32.          0.9,  0.7, -1.0,
  33.          1.0, -1.1, -0.8,
  34.         -1.0, -0.8, -0.7,
  35.         -0.6,  1.0, -0.9 };
  36.  
  37.     float dcube2[8][3] = {
  38.         -0.8,  0.9,  1.0,
  39.         -1.0, -1.0,  0.5,
  40.          1.0, -0.9,  0.8, 
  41.          0.7,  1.0,  1.1,
  42.          0.7,  0.9, -0.9,
  43.          1.1, -0.8, -1.0,
  44.         -0.7, -0.9, -0.9,
  45.         -0.9,  0.9, -1.0 };
  46.  
  47.     /************/
  48.     /* pyramids */
  49.     /************/
  50.  
  51.     float pyramid[8][3] = {
  52.         -0.1,  1.0,  0.1,
  53.         -1.0, -1.0,  1.0,
  54.          1.0, -1.0,  1.0, 
  55.          0.1,  1.0,  0.1,
  56.          0.1,  1.0, -0.1,
  57.          1.0, -1.0, -1.0,
  58.         -1.0, -1.0, -1.0,
  59.         -0.1,  1.0, -0.1 };
  60.  
  61.     float pyramid2[8][3] = {
  62.         -1.0,  1.0,  1.0,
  63.         -1.0, -1.0,  1.0,
  64.          1.0, -1.0,  1.0, 
  65.          1.0,  1.0,  1.0,
  66.          0.2,  0.2, -1.0,
  67.          0.2, -0.2, -1.0,
  68.         -0.2, -0.2, -1.0,
  69.         -0.2,  0.2, -1.0 };
  70.  
  71.     float pyramid3[8][3] = {
  72.         -0.4,  1.0,  0.4,
  73.         -1.0, -1.0,  1.0,
  74.          1.0, -1.0,  1.0, 
  75.          0.4,  1.0,  0.4,
  76.          0.4,  1.0, -0.4,
  77.          1.0, -1.0, -1.0,
  78.         -1.0, -1.0, -1.0,
  79.         -0.4,  1.0, -0.4 };
  80.  
  81.     float pyramid4[8][3] = {
  82.         -0.1,  1.0,  1.0,
  83.         -1.0, -1.0,  1.0,
  84.          1.0, -1.0,  1.0, 
  85.          0.1,  1.0,  1.0,
  86.          0.1,  1.0, -1.0,
  87.          1.0, -1.0, -1.0,
  88.         -1.0, -1.0, -1.0,
  89.         -0.1,  1.0, -1.0 };
  90.  
  91.     float pyramid5[8][3] = {
  92.         -1,    1.0,  1,
  93.          0,   -1.0,  0,
  94.          0,   -1.0,  0, 
  95.          1,    1.0,  1,
  96.          1,    1.0, -1,
  97.          0,   -1.0,  0,
  98.          0,   -1.0,  0,
  99.         -1,    1.0, -1 };
  100.  
  101.     float pyramid6[8][3] = {
  102.         -1.0,  1.0,  0.1,
  103.         -1.0, -1.0,  1.0,
  104.          1.0, -1.0,  1.0, 
  105.          1.0,  1.0,  0.1,
  106.          1.0,  1.0, -0.1,
  107.          1.0, -1.0, -1.0,
  108.         -1.0, -1.0, -1.0,
  109.         -1.0,  1.0, -0.1 };
  110.  
  111.     float pyramid7[8][3] = {
  112.         0,     1,  1,
  113.         0,    -1,  1,
  114.         1,     0,  0, 
  115.         1,     0,  0,
  116.         1,     0,  0,
  117.         1,     0,  0,
  118.         0,    -1, -1,
  119.         0,     1, -1 };
  120.  
  121.     float pyramid8[8][3] = {
  122.         -1,    0,  0,
  123.         -1,    0,  0,
  124.          0,   -1,  1, 
  125.          0,    1,  1,
  126.          0,    1, -1,
  127.          0,   -1, -1,
  128.         -1,    0,  0,
  129.         -1,    0,  0};
  130.  
  131.     float pyramid9[8][3] = {
  132.          0,    1,  1.0,
  133.          0,   -1,  1.0,
  134.          1,   -1,  0.3, 
  135.          1,    1,  0.3,
  136.          1,    1, -0.3,
  137.          1,   -1, -0.3,
  138.          0,   -1, -1.0,
  139.          0,    1, -1.0 };
  140.  
  141.   float pyramid10[8][3] = {
  142.         -1,    1,  0.3,
  143.         -1,   -1,  0.3,
  144.          0,   -1,  1.0, 
  145.          0,    1,  1.0,
  146.          0,    1, -1.0,
  147.          0,   -1, -1.0,
  148.         -1,   -1, -0.3,
  149.         -1,    1, -0.3};
  150.  
  151.     float pyramid11[8][3] = {
  152.         -1.0,  1.0,  1.0,
  153.         -1.0, -1.0,  0.8,
  154.          1.0, -1.0,  0.8, 
  155.          1.0,  1.0,  1.0,
  156.          1.0,  1.0, -1.0,
  157.          1.0, -1.0, -0.8,
  158.         -1.0, -1.0, -0.8,
  159.         -1.0,  1.0, -1.0 };
  160.  
  161.     float pyramid13[8][3] = {
  162.         -0.1,  1.0,  1.0,
  163.         -0.1, -1.0,  1.0,
  164.          1.0, -1.0,  1.0, 
  165.          0.1,  1.0,  1.0,
  166.          0.1,  1.0, -1.0,
  167.          1.0, -1.0, -1.0,
  168.         -0.1, -1.0, -1.0,
  169.         -0.1,  1.0, -1.0 };
  170.  
  171.  
  172. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  173. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  174. /* draw a vertical cylinder                                      */
  175. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  176.  
  177. void drawCylinder(float * outcol, float * topcol, float radius,
  178.                     int nsides,  int top, int detail)
  179.     {    
  180.     float   v0[3], v1[3], v2[3], v3[3];
  181.     float   theta, theta1;
  182.     float   costheta, costheta1;
  183.     float   costhetahalf, costheta1half;
  184.     float   col[4], col2[4];
  185.     float   curve;
  186.     register int edge;
  187.     
  188.     v0[1] = v3[1] = -1;
  189.     v1[1] = v2[1] = 1;
  190.  
  191.     if (nsides < 3)
  192.         nsides = 3;
  193.     
  194.     curve = 2 * PI / nsides;
  195.     col[3] = col2[3] = outcol[3];
  196.  
  197.     if (detail < 0)
  198.         {
  199.         col[0] = col2[0] = outcol[0];
  200.         col[1] = col2[1] = outcol[1];
  201.         col[2] = col2[2] = outcol[2];
  202.         }
  203.         
  204.     for (edge = 0; edge < nsides; edge++)
  205.         {
  206.         theta = edge * curve;
  207.         theta1 = (edge+1) * curve;
  208.         
  209.         costheta = cos(theta);
  210.         costheta1 = cos(theta1);
  211.         
  212.         costhetahalf  = costheta * 0.5;
  213.         costheta1half = costheta1 * 0.5;
  214.         
  215.         v0[0] = v1[0] = 1 - sin(theta) * radius;
  216.         v2[0] = v3[0] = 1 - sin(theta1) * radius;
  217.  
  218.         v0[2] = v1[2] = 1 + costheta * radius;
  219.         v2[2] = v3[2] = 1 + costheta1 * radius;
  220.  
  221.         if (detail >= 0)
  222.             {
  223.             col[0] = (outcol[0] + costhetahalf);
  224.             col[1] = (outcol[1] + costhetahalf);
  225.             col[2] = (outcol[2] + costhetahalf);
  226.             
  227.             if (col[0] > 1)
  228.                 col[0] = 1;
  229.             if (col[1] > 1)
  230.                 col[1] = 1;
  231.             if (col[2] > 1)
  232.                 col[2] = 1;
  233.             
  234.             col2[0] = (outcol[0] + costheta1half);
  235.             col2[1] = (outcol[1] + costheta1half);
  236.             col2[2] = (outcol[2] + costheta1half);
  237.     
  238.             if (col2[0] > 1)
  239.                 col2[0] = 1;
  240.             if (col2[1] > 1)
  241.                 col2[1] = 1;
  242.             if (col2[2] > 1)
  243.                 col2[2] = 1;
  244.  
  245.             glColor4fv(col);
  246.             }
  247.  
  248.         glBegin(GL_QUADS);
  249.             glVertex3fv(v0);
  250.             glVertex3fv(v1);
  251.                             
  252.             glColor4fv(col2);
  253.  
  254.             glVertex3fv(v2);
  255.             glVertex3fv(v3);
  256.         glEnd();
  257.  
  258.         /*******/
  259.         /* top */
  260.         /*******/
  261.  
  262.         if (detail >= 0)
  263.             {
  264.             glColor4fv(topcol);
  265.             }
  266.             
  267.         if (top)
  268.             {
  269.             glBegin(GL_TRIANGLES);
  270.                 glVertex3fv(pt2);
  271.                 glVertex3fv(v2);
  272.                 glVertex3fv(v1);
  273.             glEnd();
  274.             }
  275.  
  276.         /**********/
  277.         /* bottom */
  278.         /**********/
  279.             
  280.         glBegin(GL_TRIANGLES);
  281.             glVertex3fv(pt1);
  282.             glVertex3fv(v0);
  283.             glVertex3fv(v3); 
  284.         glEnd();
  285.         }
  286.     }
  287.  
  288. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  289. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  290.  
  291. void drawClosedCylinder(float * outcol, float * topcol,
  292.                         int top, int detail)
  293.     {
  294.     GLint shadeNow;
  295.     long backNow;
  296.  
  297.     glGetIntegerv(GL_SHADE_MODEL, &shadeNow);
  298.     backNow = glIsEnabled(GL_CULL_FACE);
  299.     
  300. /*    glShadeModel(GL_SMOOTH); */
  301.     glDisable(GL_CULL_FACE);
  302.     
  303.     switch (detail)
  304.         {
  305.         case 2:     drawCylinder(outcol, topcol, 1, MORECYLINDERSIDES, top, detail);
  306.                     break;
  307.         case 1:
  308.         case 0:     
  309.         case -1:    drawCylinder(outcol, topcol, 1, CYLINDERSIDES, top, detail);
  310.                     break;
  311.         }
  312.         
  313.     if (backNow)
  314.         glEnable(GL_CULL_FACE);
  315.     else
  316.         glDisable(GL_CULL_FACE);
  317.         
  318.     glShadeModel(shadeNow);
  319.     }
  320.  
  321. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  322. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  323. /* draw a vertical cone                                          */
  324. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  325.  
  326. void drawCone(float * outcol, float * topcol, float radius, int nsides, int top)
  327.     {
  328.     float   n1a,  n1b,  n2a,  n2b;
  329.     float   v0[3], v1[3], v2[3], v3[3];
  330.     float   theta, theta1;
  331.     float   costheta, costheta1;
  332.     float   col[4], col2[4];
  333.     float   curve;
  334.     int     edge;
  335.     
  336.     v0[1] = v3[1] = -1;
  337.     v1[1] = v2[1] = 1;
  338.  
  339.   if (nsides < 3)
  340.         nsides = 3;
  341.      
  342.     curve = 2 * PI / nsides;
  343.  
  344.         for (edge = 0;  edge < nsides; edge++)
  345.             {
  346.             theta = edge * curve;
  347.             theta1 = (edge+1) * curve;
  348.  
  349.             costheta = cos(theta);
  350.             costheta1 = cos(theta1);
  351.  
  352.             n1a = -sin(theta) * radius;
  353.             n2a = -sin(theta1) * radius;
  354.  
  355.             n1b = costheta *radius;
  356.             n2b = costheta1 *radius;
  357.  
  358.             col[0] = (outcol[0] + costheta * 0.1);
  359.             col[1] = (outcol[1] + costheta * 0.1);
  360.             col[2] = (outcol[2] + costheta * 0.1);
  361.  
  362.             if (col[0] > 1)
  363.                 col[0] = 1;
  364.             if (col[1] > 1)
  365.                 col[1] = 1;
  366.             if (col[2] > 1)
  367.                 col[2] = 1;
  368.  
  369.             col2[0] = (outcol[0] + costheta1 * 0.1);
  370.             col2[1] = (outcol[1] + costheta1 * 0.1);
  371.             col2[2] = (outcol[2] + costheta1 * 0.1);
  372.  
  373.             if (col2[0] > 1)
  374.                 col2[0] = 1;
  375.             if (col2[1] > 1)
  376.                 col2[1] = 1;
  377.             if (col2[2] > 1)
  378.                 col2[2] = 1;
  379.  
  380.             v0[0] = 1 + n1a;
  381.             v1[0] = 1 + n1a/6;
  382.             v0[2] = 1 + n1b;
  383.             v1[2] = 1 + n1b/6;
  384.  
  385.             v2[0] = 1 + n2a/6;
  386.             v3[0] = 1 + n2a;
  387.             v2[2] = 1 + n2b/6;
  388.             v3[2] = 1 + n2b;
  389.  
  390.             glColor3fv(col);
  391.  
  392.             glBegin(GL_QUADS);
  393.                 glVertex3fv(v0);
  394.                 glVertex3fv(v1);
  395.                                 
  396.                 glColor3fv(col2);
  397.  
  398.                 glVertex3fv(v2);
  399.                 glVertex3fv(v3);
  400.             glEnd();
  401.  
  402.             glColor3fv(topcol);
  403.                 
  404.             if (top)
  405.                 {
  406.                 glBegin(GL_TRIANGLES);
  407.                     glVertex3fv(pt2);
  408.                     glVertex3fv(v2);
  409.                     glVertex3fv(v1);
  410.                 glEnd();
  411.                 }
  412.                 
  413.             glBegin(GL_TRIANGLES);
  414.                 glVertex3fv(pt1);
  415.                 glVertex3fv(v0);
  416.                 glVertex3fv(v3); 
  417.             glEnd();
  418.         }
  419.    }
  420.  
  421. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  422. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  423.  
  424. void drawClosedCone(float * outcol, float * topcol,  int top)
  425.     {
  426.     GLint shadeNow;
  427.     long backNow;
  428.     
  429.     glGetIntegerv(GL_SHADE_MODEL, &shadeNow);
  430.     backNow = glIsEnabled(GL_CULL_FACE);
  431.  
  432.     glShadeModel(GL_SMOOTH);
  433.     glDisable(GL_CULL_FACE);
  434.  
  435.     drawCone(outcol,  topcol,  1, MORECYLINDERSIDES,  top);
  436.         
  437.     if (backNow)
  438.         glEnable(GL_CULL_FACE);
  439.     else
  440.         glDisable(GL_CULL_FACE);
  441.         
  442.     glShadeModel(shadeNow);
  443.      }
  444.  
  445. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  446. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  447. /* draw a generic6 sided object (box, damaged box, pyramid)      */
  448. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  449.  
  450. void maker(float tail2[8][3], float x,  float y,  float z,
  451.                 float u,  float v,  float w, 
  452.                 float c[4],  float d1,  float d2,  float d3,  float d4)
  453.     {
  454.     float c1[4],  c2[4],  c3[4],  c4[4];
  455.     float tail1[8][3];
  456.  
  457.     tail1[0][0] = tail2[0][0] * u + x;
  458.     tail1[0][1] = tail2[0][1] * v + y;
  459.     tail1[0][2] = tail2[0][2] * w + z;
  460.     tail1[1][0] = tail2[1][0] * u + x;
  461.     tail1[1][1] = tail2[1][1] * v + y;
  462.     tail1[1][2] = tail2[1][2] * w + z;
  463.     tail1[2][0] = tail2[2][0] * u + x;
  464.     tail1[2][1] = tail2[2][1] * v + y;
  465.     tail1[2][2] = tail2[2][2] * w + z;
  466.     tail1[3][0] = tail2[3][0] * u + x;
  467.     tail1[3][1] = tail2[3][1] * v + y;
  468.     tail1[3][2] = tail2[3][2] * w + z;
  469.     tail1[4][0] = tail2[4][0] * u + x;
  470.     tail1[4][1] = tail2[4][1] * v + y;
  471.     tail1[4][2] = tail2[4][2] * w + z;
  472.     tail1[5][0] = tail2[5][0] * u + x;
  473.     tail1[5][1] = tail2[5][1] * v + y;
  474.     tail1[5][2] = tail2[5][2] * w + z;
  475.     tail1[6][0] = tail2[6][0] * u + x;
  476.     tail1[6][1] = tail2[6][1] * v + y;
  477.     tail1[6][2] = tail2[6][2] * w + z;
  478.     tail1[7][0] = tail2[7][0] * u + x;
  479.     tail1[7][1] = tail2[7][1] * v + y;
  480.     tail1[7][2] = tail2[7][2] * w + z;
  481.  
  482.  
  483.     c1[3] = c2[3] = c3[3] = c4[3] = c[3];   
  484.     c1[0] = c[0]*d1;
  485.     c1[1] = c[1]*d1;
  486.     c1[2] = c[2]*d1;
  487.  
  488.     c2[0] = c[0]*d2;
  489.     c2[1] = c[1]*d2;
  490.     c2[2] = c[2]*d2;
  491.  
  492.     c3[0] = c[0]*d3;
  493.     c3[1] = c[1]*d3;
  494.     c3[2] = c[2]*d3;
  495.  
  496.     c4[0] = c[0]*d4;
  497.     c4[1] = c[1]*d4;
  498.     c4[2] = c[2]*d4;
  499.  
  500.     glBegin(GL_QUAD_STRIP);
  501.         glColor4fv(c2);
  502.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);glVertex3fv(tail1[3]);glVertex3fv(tail1[2]);
  503.         glColor4fv(c3);
  504.         glVertex3fv(tail1[4]);glVertex3fv(tail1[5]); 
  505.         glColor4fv(c4);
  506.         glVertex3fv(tail1[7]);glVertex3fv(tail1[6]);
  507.         glColor4fv(c3);
  508.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  509.     glEnd();            
  510.     glColor4fv(c4);
  511.  
  512.     glBegin(GL_QUADS);
  513.         glVertex3fv(tail1[6]); glVertex3fv(tail1[5]); glVertex3fv(tail1[2]); glVertex3fv(tail1[1]);
  514.  
  515.         glColor4fv(c1);
  516.  
  517.         glVertex3fv(tail1[0]); glVertex3fv(tail1[3]); glVertex3fv(tail1[4]); glVertex3fv(tail1[7]);
  518.     glEnd();
  519.     }
  520.  
  521. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  522.  
  523. void makerVapour(float x,  float y,  float z,
  524.                 float u,  float v,  float w)
  525.     {
  526.     float tail1[8][3];
  527.  
  528.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w + z;    
  529.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u + x;
  530.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;  
  531.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = x - u;
  532.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = y - v;
  533.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = z - w;
  534.  
  535.     glBegin(GL_QUAD_STRIP);
  536.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  537.         glVertex3fv(tail1[3]);glVertex3fv(tail1[2]);
  538.         glVertex3fv(tail1[4]);glVertex3fv(tail1[5]); 
  539.         glVertex3fv(tail1[7]);glVertex3fv(tail1[6]);
  540.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  541.     glEnd();            
  542.  
  543.     glBegin(GL_QUADS);
  544.         glVertex3fv(tail1[6]); glVertex3fv(tail1[5]);
  545.         glVertex3fv(tail1[2]); glVertex3fv(tail1[1]);
  546.  
  547.         glVertex3fv(tail1[0]); glVertex3fv(tail1[3]);
  548.         glVertex3fv(tail1[4]); glVertex3fv(tail1[7]);
  549.     glEnd();
  550.     }
  551.  
  552. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  553. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  554. /* draw a damaged box                                            */
  555. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  556.  
  557. void makeitd(int matrx,  float * color,  float x,  float y,  float z,
  558.                 float u,  float v,  float w)
  559.     {
  560.     if (matrx == 0)
  561.         maker(dcube, x, y, z, u, v, w, color, 0.4, 0.3, 0.2, 0.1);
  562.     else
  563.         maker(dcube2, x, y, z, u, v, w, color, 0.4, 0.3, 0.2, 0.1);
  564. }
  565.  
  566. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  567.  
  568. void makerP(float tail2[8][3], float c[4], float x,  float y,  float z,
  569.                 float u,  float v,  float w)
  570.     {
  571.     float c1[4],  c2[4],  c3[4],  c4[4];
  572.     float tail1[8][3];
  573.  
  574.     tail1[0][0] = tail2[0][0] * u + x;
  575.     tail1[0][1] = tail2[0][1] * v + y;
  576.     tail1[0][2] = tail2[0][2] * w + z;
  577.     tail1[1][0] = tail2[1][0] * u + x;
  578.     tail1[1][1] = tail2[1][1] * v + y;
  579.     tail1[1][2] = tail2[1][2] * w + z;
  580.     tail1[2][0] = tail2[2][0] * u + x;
  581.     tail1[2][1] = tail2[2][1] * v + y;
  582.     tail1[2][2] = tail2[2][2] * w + z;
  583.     tail1[3][0] = tail2[3][0] * u + x;
  584.     tail1[3][1] = tail2[3][1] * v + y;
  585.     tail1[3][2] = tail2[3][2] * w + z;
  586.     tail1[4][0] = tail2[4][0] * u + x;
  587.     tail1[4][1] = tail2[4][1] * v + y;
  588.     tail1[4][2] = tail2[4][2] * w + z;
  589.     tail1[5][0] = tail2[5][0] * u + x;
  590.     tail1[5][1] = tail2[5][1] * v + y;
  591.     tail1[5][2] = tail2[5][2] * w + z;
  592.     tail1[6][0] = tail2[6][0] * u + x;
  593.     tail1[6][1] = tail2[6][1] * v + y;
  594.     tail1[6][2] = tail2[6][2] * w + z;
  595.     tail1[7][0] = tail2[7][0] * u + x;
  596.     tail1[7][1] = tail2[7][1] * v + y;
  597.     tail1[7][2] = tail2[7][2] * w + z;
  598.  
  599.     c1[3] = c2[3] = c3[3] = c4[3] = c[3];   
  600.     c1[0] = c[0];
  601.     c1[1] = c[1];
  602.     c1[2] = c[2];
  603.  
  604.     c2[0] = c[0]*0.8;
  605.     c2[1] = c[1]*0.8;
  606.     c2[2] = c[2]*0.8;
  607.  
  608.     c3[0] = c[0]*0.66;
  609.     c3[1] = c[1]*0.66;
  610.     c3[2] = c[2]*0.66;
  611.  
  612.     c4[0] = c[0]*0.5;
  613.     c4[1] = c[1]*0.5;
  614.     c4[2] = c[2]*0.5;
  615.  
  616.     glBegin(GL_QUAD_STRIP);
  617.         glColor4fv(c2);
  618.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);glVertex3fv(tail1[3]);glVertex3fv(tail1[2]);
  619.         glColor4fv(c3);
  620.         glVertex3fv(tail1[4]);glVertex3fv(tail1[5]); 
  621.         glColor4fv(c4);
  622.         glVertex3fv(tail1[7]);glVertex3fv(tail1[6]);
  623.         glColor4fv(c3);
  624.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  625.     glEnd();            
  626.     glColor4fv(c4);
  627.  
  628.     glBegin(GL_QUADS);
  629.         glVertex3fv(tail1[6]); glVertex3fv(tail1[5]); glVertex3fv(tail1[2]); glVertex3fv(tail1[1]);
  630.  
  631.         glColor4fv(c1);
  632.  
  633.         glVertex3fv(tail1[0]); glVertex3fv(tail1[3]); glVertex3fv(tail1[4]); glVertex3fv(tail1[7]);
  634.     glEnd();
  635.     }
  636.  
  637.  
  638. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  639.  
  640. void makerFire(float c[4], float x,  float y,  float z,
  641.                 float u,  float v,  float w)
  642.     {
  643.     float tail1[8][3];
  644.  
  645.     tail1[0][0] = tail1[3][0] = tail1[4][0] = tail1[7][0] = x;
  646.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;
  647.     tail1[0][2] = tail1[3][2] = tail1[4][2] = tail1[7][2] = z;
  648.     tail1[1][0] = tail1[6][0] = - u + x;
  649.     tail1[1][1] = tail1[2][1] = - v + y;
  650.     tail1[1][2] = tail1[2][2] = w + z;
  651.     tail1[2][0] = tail1[5][0] = u + x;
  652.     tail1[5][1] = tail1[6][1] = - v + y;
  653.     tail1[5][2] = tail1[6][2] = - w + z;
  654.     
  655.     
  656.     glColor4fv(c);
  657.  
  658.     glBegin(GL_QUAD_STRIP);
  659.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);glVertex3fv(tail1[3]);glVertex3fv(tail1[2]);
  660.         glVertex3fv(tail1[4]);glVertex3fv(tail1[5]); 
  661.         glVertex3fv(tail1[7]);glVertex3fv(tail1[6]);
  662.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  663.     glEnd();            
  664.     }
  665.  
  666. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  667. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  668. /* draw a pyramid                                                */
  669. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  670.  
  671. void makeitPyr(int type,  float * color,  float x,  float y,  float z,
  672.                 float u,  float v,  float w)
  673.     {
  674.     switch(type){
  675.         case 12:makerFire(color, x, y, z, u, v, w);
  676.                 break;
  677.         case 1: makerP(pyramid, color, x, y, z, u, v, w);
  678.                 break;
  679.         case 2: makerP(pyramid2, color, x, y, z, u, v, w);
  680.                 break;
  681.         case 3: makerP(pyramid3, color, x, y, z, u, v, w);
  682.                 break;
  683.         case 4: makerP(pyramid4, color, x, y, z, u, v, w);
  684.                 break;
  685.         case 5: makerP(pyramid5, color, x, y, z, u, v, w);
  686.                 break;
  687.         case 6: makerP(pyramid6, color, x, y, z, u, v, w);
  688.                 break;
  689.         case 7: makerP(pyramid7, color, x, y, z, u, v, w);
  690.                 break;
  691.         case 8: makerP(pyramid8, color, x, y, z, u, v, w);
  692.                 break;
  693.         case 9: makerP(pyramid9, color, x, y, z, u, v, w);
  694.                 break;
  695.         case 10:makerP(pyramid10, color, x, y, z, u, v, w);
  696.                 break;
  697.         case 11:makerP(pyramid11, color, x, y, z, u, v, w);
  698.                 break;
  699.         case 13:makerP(pyramid13, color, x, y, z, u, v, w);
  700.                 break;
  701.  
  702.         default:showError("Bogus Pyramid Type! (makeitPyr)");
  703.                 break;
  704.     }
  705. }
  706.  
  707. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  708.  
  709. void makerlogo(float x,  float y,  float z,
  710.                float u,  float v,  float w, int detail, int l, int r)
  711.     {
  712.     float c[3] = {1, 1, 1};
  713.     float c3[3] = {0.7, 0.7, 0.7};
  714.     float c5[3] ={0, 0, 0};
  715.     float tail1[8][3];
  716.  
  717.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w + z;    
  718.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u + x;
  719.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;  
  720.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = x - u;
  721.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = y - v;
  722.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = z - w;
  723.     
  724.  
  725.     glBegin(GL_QUADS);
  726.  
  727.         if (detail != -1)
  728.             {
  729.             glColor3fv(c);
  730.     
  731.             /* right */
  732.     
  733.             if (r)
  734.                 {
  735.                 glVertex3fv(tail1[3]); glVertex3fv(tail1[2]);
  736.                 glVertex3fv(tail1[5]); glVertex3fv(tail1[4]);
  737.                 }
  738.     
  739.             /* left */
  740.     
  741.             if (l)
  742.                 {
  743.                 glVertex3fv(tail1[7]); glVertex3fv(tail1[6]);
  744.                 glVertex3fv(tail1[1]); glVertex3fv(tail1[0]);
  745.                 }
  746.     
  747.             if (detail > 0)
  748.                 glColor3fv(c3);
  749.     
  750.             /* bottom */
  751.                     
  752.             glVertex3fv(tail1[6]); glVertex3fv(tail1[5]);
  753.             glVertex3fv(tail1[2]); glVertex3fv(tail1[1]);
  754.             }
  755.             
  756.         if (detail == -1)
  757.             glColor4fv(c3);
  758.         else
  759.             glColor4fv(c5);
  760.  
  761.         /* front */
  762.  
  763.         glVertex3fv(tail1[0]); glVertex3fv(tail1[1]);
  764.         glVertex3fv(tail1[2]); glVertex3fv(tail1[3]);
  765.  
  766.     glEnd();
  767.     
  768.     }
  769.  
  770. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  771. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  772. /* draw a cube                                                   */
  773. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  774.  
  775. void makercube(float x,  float y,  float z,
  776.                 float u,  float v,  float w, 
  777.                 float c[4])
  778.     {
  779.     float c2[4],  c3[4],  c4[4];
  780.     float tail1[8][3];
  781.  
  782.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w + z;    
  783.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u + x;
  784.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;  
  785.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = x - u;
  786.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = y - v;
  787.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = z - w;
  788.     
  789.     c2[3] = c3[3] = c4[3] = c[3];   
  790.  
  791.     c2[0] = c[0]*0.8;
  792.     c2[1] = c[1]*0.8;
  793.     c2[2] = c[2]*0.8;
  794.  
  795.     c3[0] = c[0]*0.66;
  796.     c3[1] = c[1]*0.66;
  797.     c3[2] = c[2]*0.66;
  798.  
  799.     c4[0] = c[0]*0.5;
  800.     c4[1] = c[1]*0.5;
  801.     c4[2] = c[2]*0.5;
  802.  
  803.     glBegin(GL_QUAD_STRIP);
  804.         glColor4fv(c2);
  805.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);glVertex3fv(tail1[3]);glVertex3fv(tail1[2]);
  806.         glColor4fv(c3);
  807.         glVertex3fv(tail1[4]);glVertex3fv(tail1[5]); 
  808.         glColor4fv(c4);
  809.         glVertex3fv(tail1[7]);glVertex3fv(tail1[6]);
  810.         glColor4fv(c3);
  811.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  812.     glEnd();    
  813.         
  814.     glColor4fv(c4);
  815.  
  816.     glBegin(GL_QUADS);
  817.         glVertex3fv(tail1[6]); glVertex3fv(tail1[5]); glVertex3fv(tail1[2]); glVertex3fv(tail1[1]);
  818.     
  819.         glColor4fv(c);
  820.  
  821.         glVertex3fv(tail1[0]); glVertex3fv(tail1[3]); glVertex3fv(tail1[4]); glVertex3fv(tail1[7]);
  822.     glEnd();
  823.     }
  824.  
  825. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  826.  
  827. void makerbluecube(float x,  float y,  float z,
  828.                 float u,  float v,  float w, 
  829.                 float c[4])
  830.     {
  831.     float tail1[8][3];
  832.  
  833.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w + z;    
  834.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u + x;
  835.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;  
  836.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = x - u;
  837.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = y - v;
  838.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = z - w;
  839.     
  840.     glColor4fv(c);
  841.  
  842.     glBegin(GL_QUAD_STRIP);
  843.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);glVertex3fv(tail1[3]);glVertex3fv(tail1[2]);
  844.         glVertex3fv(tail1[4]);glVertex3fv(tail1[5]); 
  845.         glVertex3fv(tail1[7]);glVertex3fv(tail1[6]);
  846.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  847.     glEnd();    
  848.         
  849.  
  850.     glBegin(GL_QUADS);
  851.         glVertex3fv(tail1[6]); glVertex3fv(tail1[5]); glVertex3fv(tail1[2]); glVertex3fv(tail1[1]);
  852.         glVertex3fv(tail1[0]); glVertex3fv(tail1[3]); glVertex3fv(tail1[4]); glVertex3fv(tail1[7]);
  853.     glEnd();
  854.     }
  855.  
  856. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  857. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  858. /* draw a cube with only a back and a top (for monsterview goog) */
  859. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  860.  
  861. void makercubeTopBack(float x,  float y,  float z,
  862.                 float u,  float v,  float w, 
  863.                 float c[4])
  864.     {
  865.     float c4[4];
  866.     float tail1[8][3];
  867.  
  868.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w + z;    
  869.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u + x;
  870.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;  
  871.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = x - u;
  872.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = y - v;
  873.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = z - w;
  874.  
  875.     c4[0] = c[0]*0.5;
  876.     c4[1] = c[1]*0.5;
  877.     c4[2] = c[2]*0.5;
  878.     c4[3] = c[3];   
  879.  
  880.     glBegin(GL_QUAD_STRIP);
  881.         glColor4fv(c);
  882.         glVertex3fv(tail1[0]);glVertex3fv(tail1[3]); 
  883.         glVertex3fv(tail1[7]);glVertex3fv(tail1[4]);
  884.         glColor4fv(c4);
  885.         glVertex3fv(tail1[6]);glVertex3fv(tail1[5]);
  886.     glEnd();    
  887.     }
  888.  
  889. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  890. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  891. /* draw a cube with no bottom                                    */
  892. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  893.  
  894. void makercubenobtm(float x,  float y,  float z,
  895.                 float u,  float v,  float w, 
  896.                 float c[4])
  897.     {
  898.     float c2[4],  c3[4],  c4[4];
  899.     float tail1[8][3];
  900.  
  901.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w + z;    
  902.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u + x;
  903.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;  
  904.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = x - u;
  905.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = y - v;
  906.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = z - w;
  907.  
  908.  
  909.     c2[3] = c3[3] = c4[3] = c[3];   
  910.  
  911.     c2[0] = c[0]*0.8;
  912.     c2[1] = c[1]*0.8;
  913.     c2[2] = c[2]*0.8;
  914.  
  915.     c3[0] = c[0]*0.66;
  916.     c3[1] = c[1]*0.66;
  917.     c3[2] = c[2]*0.66;
  918.  
  919.     c4[0] = c[0]*0.5;
  920.     c4[1] = c[1]*0.5;
  921.     c4[2] = c[2]*0.5;
  922.  
  923.     glBegin(GL_QUAD_STRIP);
  924.         glColor4fv(c2);
  925.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);glVertex3fv(tail1[3]);glVertex3fv(tail1[2]);
  926.         glColor4fv(c3);
  927.         glVertex3fv(tail1[4]);glVertex3fv(tail1[5]); 
  928.         glColor4fv(c4);
  929.         glVertex3fv(tail1[7]);glVertex3fv(tail1[6]);
  930.         glColor4fv(c3);
  931.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  932.     glEnd();    
  933.         
  934.     glColor4fv(c);
  935.  
  936.     glBegin(GL_QUADS);
  937.         glVertex3fv(tail1[0]); glVertex3fv(tail1[3]); glVertex3fv(tail1[4]); glVertex3fv(tail1[7]);
  938.     glEnd();
  939.     }
  940.  
  941. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  942. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  943. /* draw a cube with no bottom and no top                         */
  944. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  945.  
  946. void makercubenobtmnotop(float x,  float y,  float z,
  947.                 float u,  float v,  float w, 
  948.                 float c[4])
  949.     {
  950.     float c2[4],  c3[4],  c4[4];
  951.     float tail1[8][3];
  952.  
  953.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w + z;    
  954.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u + x;
  955.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;  
  956.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = x - u;
  957.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = y - v;
  958.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = z - w;
  959.  
  960.  
  961.     c2[3] = c3[3] = c4[3] = c[3];   
  962.  
  963.     c2[0] = c[0]*0.8;
  964.     c2[1] = c[1]*0.8;
  965.     c2[2] = c[2]*0.8;
  966.  
  967.     c3[0] = c[0]*0.66;
  968.     c3[1] = c[1]*0.66;
  969.     c3[2] = c[2]*0.66;
  970.  
  971.     c4[0] = c[0]*0.5;
  972.     c4[1] = c[1]*0.5;
  973.     c4[2] = c[2]*0.5;
  974.  
  975.     glBegin(GL_QUAD_STRIP);
  976.         glColor4fv(c2);
  977.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);glVertex3fv(tail1[3]);glVertex3fv(tail1[2]);
  978.         glColor4fv(c3);
  979.         glVertex3fv(tail1[4]);glVertex3fv(tail1[5]); 
  980.         glColor4fv(c4);
  981.         glVertex3fv(tail1[7]);glVertex3fv(tail1[6]);
  982.         glColor4fv(c3);
  983.         glVertex3fv(tail1[0]);glVertex3fv(tail1[1]);
  984.     glEnd();            
  985.     }
  986.  
  987. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  988. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  989. /* draw a cube with no bottom and no top assigning texture coords*/
  990. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  991.  
  992. void makercubenobtmnotopTEX(float x,  float y,  float z,
  993.                 float u,  float v,  float w, 
  994.                 float c[4])
  995.     {
  996.     float c2[4],  c3[4],  c4[4];
  997.     float tail1[8][3];
  998.  
  999.     static float tv1[2] = {0,1};
  1000.     static float tv2[2] = {1,1};
  1001.     static float tv3[2] = {1,0};
  1002.     static float tv4[2] = {0,0};
  1003.  
  1004.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w + z;    
  1005.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u + x;
  1006.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v + y;  
  1007.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = x - u;
  1008.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = y - v;
  1009.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = z - w;
  1010.  
  1011.  
  1012.  
  1013.     c2[3] = c3[3] = c4[3] = c[3];   
  1014.  
  1015.     c2[0] = c[0]*0.8;
  1016.     c2[1] = c[1]*0.8;
  1017.     c2[2] = c[2]*0.8;
  1018.  
  1019.     c3[0] = c[0]*0.66;
  1020.     c3[1] = c[1]*0.66;
  1021.     c3[2] = c[2]*0.66;
  1022.  
  1023.     c4[0] = c[0]*0.5;
  1024.     c4[1] = c[1]*0.5;
  1025.     c4[2] = c[2]*0.5;
  1026.  
  1027.     glBegin(GL_QUAD_STRIP);
  1028.     
  1029.         glColor4fv(c2);
  1030.         glTexCoord2fv(tv2);
  1031.         glVertex3fv(tail1[0]);
  1032.         glTexCoord2fv(tv3);
  1033.         glVertex3fv(tail1[1]);
  1034.         glTexCoord2fv(tv1);
  1035.         glVertex3fv(tail1[3]);
  1036.         glTexCoord2fv(tv4);
  1037.         glVertex3fv(tail1[2]);
  1038.         
  1039.         glColor4fv(c3);
  1040.         glTexCoord2fv(tv2);
  1041.         glVertex3fv(tail1[4]);
  1042.         glTexCoord2fv(tv3);
  1043.         glVertex3fv(tail1[5]); 
  1044.         
  1045.         glColor4fv(c4);
  1046.         glTexCoord2fv(tv1);
  1047.         glVertex3fv(tail1[7]);
  1048.         glTexCoord2fv(tv4);
  1049.         glVertex3fv(tail1[6]);
  1050.         
  1051.         glColor4fv(c3);
  1052.         glTexCoord2fv(tv2);
  1053.         glVertex3fv(tail1[0]);
  1054.         glTexCoord2fv(tv3);
  1055.         glVertex3fv(tail1[1]);
  1056.     glEnd();            
  1057.     }
  1058.  
  1059. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1060. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1061. /* draw a cube rotated around the x and y axis                   */
  1062. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1063.  
  1064. void makerrotcubexy(float u,  float v,  float w, 
  1065.                 float theta, float c[4])
  1066.     {
  1067.     float c2[4],  c3[4],  c4[4];
  1068.  
  1069.     float tail1[8][3];
  1070.     float tail2[8][3];
  1071.     register int i;
  1072.     float thetaRad, cthetarad, sthetarad;
  1073.     
  1074.     thetaRad = theta * BIG_DEG_TO_RAD;
  1075.     cthetarad = cos(thetaRad);
  1076.     sthetarad = sin(thetaRad);
  1077.  
  1078.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w;    
  1079.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = - w;
  1080.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u;
  1081.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = - u;
  1082.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v;  
  1083.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = - v;
  1084.  
  1085.     for (i=0;i<8;i++)
  1086.         {
  1087.         tail2[i][0] = tail1[i][0]*cthetarad + sthetarad*(tail1[i][1]*sthetarad+tail1[i][2]*cthetarad);
  1088.         tail2[i][1] = tail1[i][1]*cthetarad - tail1[i][2]*sthetarad;
  1089.         tail2[i][2] = -tail1[i][0]*sthetarad + cthetarad*(tail1[i][1]*sthetarad+tail1[i][2]*cthetarad);
  1090.         }
  1091.  
  1092.     c2[3] = c3[3] = c4[3] = c[3];   
  1093.  
  1094.     c2[0] = c[0]*0.8;
  1095.     c2[1] = c[1]*0.8;
  1096.     c2[2] = c[2]*0.8;
  1097.  
  1098.     c3[0] = c[0]*0.66;
  1099.     c3[1] = c[1]*0.66;
  1100.     c3[2] = c[2]*0.66;
  1101.  
  1102.     c4[0] = c[0]*0.5;
  1103.     c4[1] = c[1]*0.5;
  1104.     c4[2] = c[2]*0.5;
  1105.  
  1106.     glBegin(GL_QUAD_STRIP);
  1107.         glColor4fv(c2);
  1108.         glVertex3fv(tail2[0]);glVertex3fv(tail2[1]);glVertex3fv(tail2[3]);glVertex3fv(tail2[2]);
  1109.         glColor4fv(c3);
  1110.         glVertex3fv(tail2[4]);glVertex3fv(tail2[5]); 
  1111.         glColor4fv(c4);
  1112.         glVertex3fv(tail2[7]);glVertex3fv(tail2[6]);
  1113.         glColor4fv(c3);
  1114.         glVertex3fv(tail2[0]);glVertex3fv(tail2[1]);
  1115.     glEnd();            
  1116.     glColor4fv(c4);
  1117.  
  1118.     glBegin(GL_QUADS);
  1119.         glVertex3fv(tail2[6]); glVertex3fv(tail2[5]); glVertex3fv(tail2[2]); glVertex3fv(tail2[1]);
  1120.  
  1121.         glColor4fv(c);
  1122.  
  1123.         glVertex3fv(tail2[0]); glVertex3fv(tail2[3]); glVertex3fv(tail2[4]); glVertex3fv(tail2[7]);
  1124.     glEnd();
  1125.     }
  1126.  
  1127. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1128. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1129. /* draw a 1 colour cube rotated around the x and y axis          */
  1130. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1131.  
  1132. void makerrotcubexyflat(float u,  float v,  float w, 
  1133.                 float theta, float c[4])
  1134.     {
  1135.     float tail1[8][3];
  1136.     float tail2[8][3];
  1137.     register int i;
  1138.     float thetaRad, cthetarad, sthetarad;
  1139.     
  1140.     thetaRad = theta * BIG_DEG_TO_RAD;
  1141.     cthetarad = cos(thetaRad);
  1142.     sthetarad = sin(thetaRad);
  1143.  
  1144.     tail1[0][2] = tail1[1][2] = tail1[2][2] = tail1[3][2] = w;    
  1145.     tail1[4][2] = tail1[5][2] = tail1[6][2] = tail1[7][2] = - w;
  1146.     tail1[2][0] = tail1[3][0] = tail1[4][0] = tail1[5][0] = u;
  1147.     tail1[0][0] = tail1[1][0] = tail1[6][0] = tail1[7][0] = - u;
  1148.     tail1[0][1] = tail1[3][1] = tail1[4][1] = tail1[7][1] = v;  
  1149.     tail1[1][1] = tail1[2][1] = tail1[5][1] = tail1[6][1] = - v;
  1150.  
  1151.     for (i=0;i<8;i++)
  1152.         {
  1153.         tail2[i][0] = tail1[i][0]*cthetarad + sthetarad*(tail1[i][1]*sthetarad+tail1[i][2]*cthetarad);
  1154.         tail2[i][1] = tail1[i][1]*cthetarad - tail1[i][2]*sthetarad;
  1155.         tail2[i][2] = -tail1[i][0]*sthetarad + cthetarad*(tail1[i][1]*sthetarad+tail1[i][2]*cthetarad);
  1156.         }
  1157.  
  1158.     glColor4fv(c);
  1159.  
  1160.     glBegin(GL_QUAD_STRIP);
  1161.         glVertex3fv(tail2[0]);glVertex3fv(tail2[1]);glVertex3fv(tail2[3]);glVertex3fv(tail2[2]);
  1162.         glVertex3fv(tail2[4]);glVertex3fv(tail2[5]); 
  1163.         glVertex3fv(tail2[7]);glVertex3fv(tail2[6]);
  1164.         glVertex3fv(tail2[0]);glVertex3fv(tail2[1]);
  1165.     glEnd();            
  1166.  
  1167.     glBegin(GL_QUADS);
  1168.         glVertex3fv(tail2[6]); glVertex3fv(tail2[5]); glVertex3fv(tail2[2]); glVertex3fv(tail2[1]);
  1169.         glVertex3fv(tail2[0]); glVertex3fv(tail2[3]); glVertex3fv(tail2[4]); glVertex3fv(tail2[7]);
  1170.     glEnd();
  1171.     }
  1172.  
  1173. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1174.  
  1175. void andysphdraw(float loc[4], int count)
  1176.     {
  1177.     if (count == 0)
  1178.         {
  1179.         float radius;
  1180.         
  1181.         radius = loc[3] / 1.5;
  1182.         makerVapour(loc[0], loc[1], loc[2], radius, radius, radius);    
  1183.         }
  1184.     else
  1185.         {
  1186.         qobj = gluNewQuadric();
  1187.     
  1188.         if (qobj != NULL)
  1189.             {
  1190.             glPushMatrix();
  1191.                 glTranslatef(loc[0], loc[1], loc[2]);
  1192.                 gluSphere( qobj, loc[3], count*3, count*3); /* was count*4 */
  1193.             glPopMatrix();
  1194.             gluDeleteQuadric(qobj);
  1195.             }
  1196.         }
  1197.     }
  1198.